package com.csust.automaticteach.model.vo.exercises;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.csust.automaticteach.model.entity.Exercises;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @ClassNameExercisesVO
 * @Description 题目视图 VO
 * @Author钰玟
 * @Date2025/7/24 下午2:35
 * @Version 1.0
 **/
@Data
public class ExercisesVO implements Serializable {
    /**
     * id
     */
    private Long id;

    /**
     * 题目标题
     */
    private String title;

    /**
     * 题目内容
     */
    private String content;

    /**
     * 题目类型
     */
    private String type;

    /**
     * 选择题选项数组
     */
    private List<String> options;

    /**
     * 正确答案
     */
    private String answer;

    /**
     * 题目解析
     */
    private String explanation;

    /**
     * 题目难度
     */
    private String difficulty;

    /**
     * 知识点
     */
    private String knowledgePoint;


    private static final long serialVersionUID = 1L;

    public static ExercisesVO objToVO(Exercises exercises) {
        ExercisesVO exercisesVO = new ExercisesVO();
        BeanUtil.copyProperties(exercises, exercisesVO);
        String jsonOptions = exercises.getOptions();
        List<String> options = JSONUtil.toList(jsonOptions, String.class);
        exercisesVO.setOptions(options);
        return exercisesVO;
    }
    public static Exercises voToObj(ExercisesVO exercisesVO) {
        Exercises exercises = new Exercises();
        BeanUtil.copyProperties(exercisesVO, exercises);
        String jsonOptions = JSONUtil.toJsonStr(exercisesVO.getOptions());
        exercises.setOptions(jsonOptions);
        return exercises;
    }
}
